<?php  ?>

<div class="row-fluid sortable ui-sortable">
	<div id="gchart-daging-sapi-prov" class="box span12">
		<div class="box-header well" data-original-title>
			<h2 id="action-title">Perbandingan Permintan dan Penjualan Per Provinsi</h2>
		</div>
		<div class="box-content">
			<div id="chart-daging-sapi-prov" style="height:900px;">
			</div>
		</div>
	</div>
</div>

<script>
	/* Chart Pertambahan Pengurangan */
	function drawChartStokProv(){
		if($("#chart-daging-sapi-prov").length)
		{
			<?php
				echo 'var permintaan = [], penjualan = [], ticks = [];';
				
				for($i=0; $i<count($stok_prov); $i++){
					echo 'permintaan.push([ '.$stok_prov[$i]['permintaan'].', '.$i.']);';
					echo 'penjualan.push(['.$stok_prov[$i]['penjualan'].', '.$i.']);';
					echo 'ticks.push(['.$i.', "'.$stok_prov[$i]['nama_prov'].'"]);';
				}
				
				echo 'var datasetProv = [
					{ label: "Permintaan", data: permintaan
						, bars: {
							show: true,
							fill: true,
							barWidth: 0.25
						}},
					{ label: "Penjualan", data: penjualan
						, bars: {
							show: true,
							fill: true,
							barWidth: 0.25
						}}
				];';
			
			?>
			
			
			var plot = $.plot($("#chart-daging-sapi-prov"),
					datasetProv, {					
					   series: {
						   bars: { show: true , fill: true }
					   },
					   bars:{
							align: "center",
							barWidth: 0.5,
							horizontal: true,
							barWidth: 0.5
					   },
					   grid: { borderWidth: 2, hoverable: true, clickable: true, backgroundColor: { colors: ["#fff", "#eee"] } },
					   yaxis: {
						ticks: ticks
					   },
					   xaxis:  { min: 0, max: <?php echo 1.75 * $max_stok; ?>},
					   colors: ["#539F2E", "#3C67A5"]
					 });
								 
			
			
			function getMonthName(month){
				if(month == '1') return "Januari";
				if(month == '2') return "Februari";
				if(month == '3') return "Maret";
				if(month == '4') return "April";
				if(month == '5') return "Mei";
				if(month == '6') return "Juni";
				if(month == '7') return "Juli";
				if(month == '8') return "Agustus";
				if(month == '9') return "September";
				if(month == '10') return "Oktober";
				if(month == '11') return "November";
				if(month == '12') return "Desember";
			}
		}
	}
	/* End Chart Pertambahan Pengurangan */
</script>